<template>

  <div>
    <z-table ref="table" rowKey="id" :showAlert="false" :showSelection="false" :loading="loading"
             :columns="columns" :dataSource="pageData" @change="onTableChange">
      <!--      <template slot="type" slot-scope="text">-->
      <!--        <span>{{ setTittle(text) }}</span>-->
      <!--      </template>-->
      <!--      <template slot="trainLevel" slot-scope="text">-->
      <!--        <span v-if="text == '1'">初级</span>-->
      <!--        <span v-if="text == '2'">中级</span>-->
      <!--        <span v-if="text == '3'">高级</span>-->
      <!--        <span v-if="text == '4'">技师</span>-->
      <!--        <span v-if="text == '5'">高级技师</span>-->
      <!--      </template>-->
      <!--      <template slot="trainCategory" slot-scope="text">-->
      <!--        <span v-if="text == '1'">A</span>-->
      <!--        <span v-if="text == '2'">B</span>-->
      <!--        <span v-if="text == '3'">C</span>-->
      <!--        <span v-if="text == '4'">D</span>-->
      <!--        <span v-if="text == '5'">E</span>-->
      <!--        <span v-if="text == '6'">F</span>-->
      <!--      </template>-->
      <!--操作-->
      <template slot="action" slot-scope="text, record">
        <!--        <a-button @click="onDetail(record)" type="link" style="padding: 0">查看</a-button>-->
      </template>
    </z-table>
    <!--    <DetailModal ref="detailModalId"/>-->
  </div>

</template>

<script>
import * as trainingApi from '@/api/sjsk/help/training.js'
import {getDictItemsFromCache} from '@/api/api'
import {downLoadFileReader} from '@/utils/export-util/util'
import DepartTree from '@/views/sjsk/modules/departTree'
import {holoArchiveEmployReset, holoArchiveSkillTrain} from "@api/sjsk/archives";
// import DetailModal from './modules/DetailModal'

export default {
  // props: ['status'],
  components: {
    DepartTree,
    // DetailModal
  },
  data() {
    return {
      labelCol: {span: 7},
      wrapperCol: {span: 16},
      loading: false,
      visible: false,
      reloading: false,
      treeDatas: [],
      toggle: true,
      columns: [],
      columns0: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '申请时间',
          dataIndex: 'salaryReq',
          align: 'center',
          customRender: (text) => {
            return <j-ellipsis value={text} length={14} />
          },
        },
        {
          title: '审批状态',
          dataIndex: 'workPlace',
          align: 'center',
          customRender: (text) => {
            return <j-ellipsis value={text} length={14} />
          },
        },
        {
          title: '操作',
          dataIndex: 'trainCategory',
          align: 'center',
        },

      ],
      columns1: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '咨询时间',
          dataIndex: 'employTime',
          align: 'center',
          customRender: (text) => {
            return <j-ellipsis value={text} length={14} />
          },
        },
        {
          title: '咨询主题',
          dataIndex: 'employUnit',
          align: 'center',
          customRender: (text) => {
            return <j-ellipsis value={text} length={14} />
          },
        },
        {
          title: '咨询内容',
          dataIndex: 'trainPlace',
          align: 'center',
          customRender: (text) => {
            return <j-ellipsis value={text} length={14} />
          },
        },
        {
          title: '操作',
          dataIndex: 'trainCategory',
          align: 'center',
        },


      ],
      pageFilter: {
        pageNo: 1,
        pageSize: 10,
        id: this.$store.state.holographicArchives.routeObjData.sjskId,
        type:'1'
      },
      status: "1",
      pageData: {},
      departmentId: "",
      typeArr: getDictItemsFromCache('personType')
    }
  },
  created() {
    this.getRouter(this.$route.name)
  },
  watch: {
    $route(data) {   //data为当前路由信息
      this.getRouter(data.name)
    },
    // 组织机构树-联动筛选人员列表
    // 'pageFilter.departmentId'(newVal, oldVal) {
    //   this.onQuery()
    // }
  },
  methods: {
    setStatus(status) {
      if(status === 0){
        this.columns = this.columns0
      }
      if(status === 1){
        this.columns = this.columns1
      }
      if(status === 2){
        this.columns = this.columns2
      }
    },
    setTittle(text) {
      return this.$filterDictTextByCache('personType', text)  //现在字典中对应的文字，是全局函数
    },
    onTableChange(pagination, pageFilter, sorter) {
      let keyMap = {currentPage: 'pageNo'}
      let paginations = Object.keys(pagination).reduce((newData, key) => {
        let newKey = keyMap[key] || key
        newData[newKey] = pagination[key]
        return newData
      }, {})
      this.pageFilter = Object.assign({}, this.pageFilter, paginations)
      this.refreshTable()
    },
    refreshTable(val) {
      this.loading = true
      // holoArchiveEmployReset(this.pageFilter)
      //   .then((res) => {
      //     if (res.success) {
      //       if(val === 0){
      //         this.pageData = res.result.empIntentionVOList ? res.result.empIntentionVOList : {}
      //       }
      //       if(val === 1){
      //         this.pageData = res.result.empResetVOList ? res.result.empResetVOList : {}
      //       }
      //       // this.pageData = res.result ? res.result : {}
      //       this.loading = false
      //     } else {
      //       this.$message.warn(res.message)
      //       this.loading = false
      //     }
      //   })
      //   .catch((e) => {
      //     this.loading = false
      //     this.$message.warn('请求失败！')
      //   })
    },

    /** 重新加载组件 */
    // reload() {
    //   this.reloading = true
    //   this.$nextTick(() => (this.reloading = false))
    // },
  },
}
</script>
<style lang="less" scoped>
.topBox /deep/ .ant-row {
  margin-bottom: 0;
}
</style>
